<?php
/*
	账户变更记录
*/

defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'credit2';
if($_RQ['op']=='credit2'){
	//余额变更记录
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['type']=2;
	if(isset($_RQ['is_add'])){
		$params['is_add']=intval($_RQ['is_add']);
		$return['params']['is_add']=$_RQ['is_add'];
	}
	if($_RQ['remark']){
		$params['remark like']='%'.trim($_RQ['remark']).'%';
		$return['params']['remark']=$_RQ['remark'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array();
	$list=pdo_getslice('core_account_credit_log',$params,array($pindex,$psize),$total,$fields,'','id desc');
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'credit2','title'=>'余额变更日志'),
			array('op'=>'credit1','title'=>'积分变更日志'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'fee','title'=>'金额','type'=>'string'),
			array('name'=>'is_add','title'=>'类型','type'=>'radio','options'=>'is_adds'),
			array('name'=>'remark','title'=>'备注','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		)),
	);
	$return['htmls']=$htmls;
	$return['is_adds']=array(
		'0'=>'减少',
		'1'=>'增加',
	);
	exi($return);
}
if($_RQ['op']=='credit1'){
	//余额变更记录
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['type']=1;
	if(isset($_RQ['is_add'])){
		$params['is_add']=intval($_RQ['is_add']);
		$return['params']['is_add']=$_RQ['is_add'];
	}
	if($_RQ['remark']){
		$params['remark like']='%'.trim($_RQ['remark']).'%';
		$return['params']['remark']=$_RQ['remark'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array();
	$list=pdo_getslice('core_account_credit_log',$params,array($pindex,$psize),$total,$fields,'','id desc');
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'credit2','title'=>'余额变更日志'),
			array('op'=>'credit1','title'=>'积分变更日志'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'fee','title'=>'金额','type'=>'string'),
			array('name'=>'is_add','title'=>'类型','type'=>'radio','options'=>'is_adds'),
			array('name'=>'remark','title'=>'备注','type'=>'string'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'time'),
		)),
	);
	$return['htmls']=$htmls;
	$return['is_adds']=array(
		'0'=>'减少',
		'1'=>'增加',
	);
	exi($return);
}
if($_RQ['op']=='del'){
	if($_RQ['del']){
		$del=str_array($_RQ['del']);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=intval($_RQ['id']);
	}
	if(!$del){
		exi('请先选择要删除的日志！','error');
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('core_account_credit_log',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}